//
//  PdfHomeController.m
//  PdfChange
//
//  Created by 蓝鳍互娱 on 2024/7/25.
//

#import "PdfHomeController.h"
#import "PdfMainController.h"
#import "PdfTopHomeView.h"
#import "PdfHomePdfChangeCell.h"
#import "PdfHomeChangePdfCell.h"
#import "PdfHomeFileCell.h"
@interface PdfHomeController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic,strong) UITableView *pdfHomeTableView;
@end

@implementation PdfHomeController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = PdfHex(@"#F7F7F9");
    [self creatPdfSubView];
}
- (void)creatPdfSubView{
    UIImageView * pdfTopImgView = [[UIImageView alloc] init];
    pdfTopImgView.image = PdfImageNamed(@"pdfHomeTopBg");
    [self.view addSubview:pdfTopImgView];
    [pdfTopImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(0)));
        make.right.equalTo(@(-PdfRatio(0)));
        make.top.equalTo(@(PdfRatio(0)));
        make.height.equalTo(@(PdfRatio(269)));
    }];
    
    PdfTopHomeView *pdfTopHomeView = [[PdfTopHomeView alloc] init];
    [self.view addSubview:pdfTopHomeView];
    [pdfTopHomeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(0)));
        make.right.equalTo(@(PdfRatio(0)));
        make.top.equalTo(@(PdfRatio(0)));
        make.height.equalTo(@(PdfRatio(245)));
    }];
    _pdfHomeTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    _pdfHomeTableView.delegate = self;
    _pdfHomeTableView.dataSource = self;
    _pdfHomeTableView.backgroundColor = [UIColor clearColor];
    _pdfHomeTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_pdfHomeTableView];
    [_pdfHomeTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(0)));
        make.right.equalTo(@(PdfRatio(0)));
        make.top.equalTo(pdfTopHomeView.mas_bottom).offset(PdfRatio(0));
        make.bottom.equalTo(@(PdfRatio(0)));
    }];
}
#pragma mark - UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return PdfRatio(429);
    }else if (indexPath.row == 1) {
        return PdfRatio(454);
    }else{
        return PdfRatio(320);
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    PdfWeakSelf
    if (indexPath.row == 0) {
        PdfHomePdfChangeCell *pdfHomePdfChangeCell = [PdfHomePdfChangeCell pdfHomePdfChangeCell:tableView];
        return pdfHomePdfChangeCell;
    }else if (indexPath.row == 1) {
        PdfHomeChangePdfCell *pdfHomeChangePdfCell = [PdfHomeChangePdfCell pdfHomeChangePdfCell:tableView];
        return pdfHomeChangePdfCell;
    }else{
        PdfHomeFileCell *pdfHomeFileCell = [PdfHomeFileCell pdfHomeFileCell:tableView];
        pdfHomeFileCell.TapHomeRelativeBlock = ^{
            
        };
        pdfHomeFileCell.TapHomeFileBlock = ^{
            
        };
        pdfHomeFileCell.TapHomeMyBlock = ^{
            PdfMainController *pdfMainCtrl = [[PdfMainController alloc] init];
            [weakSelf.navigationController pushViewController:pdfMainCtrl animated:true];
        };
        return pdfHomeFileCell;
    }
}
@end
